import { defineStore } from "pinia";
import { reqTrademarkList } from "@/api/trademark";
import type { trademarkListType } from "@/api/trademark";

export interface tmStoreStateType {
  //品牌列表
  trademarkList: trademarkListType;
  //品牌列表的总页数
  pages: number;
  total:number
}
const useTradMarkListStore = defineStore("trademark", {
  state: (): tmStoreStateType => {
    return {
      //品牌列表
      trademarkList: [],
      //品牌列表的总页数
      pages: 0,
      total:0
    };
  },
  actions: {
    async getTradeMark(page: number, limit: number) {
      try {
        const re = await reqTrademarkList(page, limit);
        this.trademarkList = re.records;
        this.pages = re.pages;
        this.total = re.total;
      } catch (e) {
        return Promise.reject(e);
      }
    },
  },
});

export default useTradMarkListStore
